package com.yonyou.gmcc.gateway.web.filter;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;


@Service
public class AwayFilter extends ZuulFilter{
	 private  Logger log = LoggerFactory.getLogger(this.getClass());

	@Override
	public Object run() {
		log.debug("======离开gateway========");
		RequestContext ctx = RequestContext.getCurrentContext();
      HttpServletRequest request = ctx.getRequest();
//      ctx.getResponse().addHeader("Access-Control-Allow-Credentials", "true");
//      ctx.getResponse().addHeader("Access-Control-Allow-Origin", "*");
//      ctx.getResponse().addHeader("Access-Control-Allow-Methods", "OPTIONS,HEAD,GET,PUT,POST,DELETE,PATCH");
//      List  list=ctx.getZuulResponseHeaders();
//      System.out.println(list);:
//      for(int i=0;i<list.size();i++){
//      	Map<String,Object>  map=(Map<String, Object>) list.get(i);
//      	System.out.println(map);
//      	for(String name:map.keySet()){
//      		System.out.println("name"+name+";"+map.get(name)+"======");
//      	}
//      }
//      System.out.println("=====");
		return null;
	}


	@Override
	public boolean shouldFilter() {
		return true;
	}

	@Override
	public int filterOrder() {
		return 999;
	}

	@Override
	public String filterType() {
		return "post";
	}

}